package julialang.tech.backend.handler;

import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MessageHandler {

  private Map<String, MessageProcessor> processors;

  public WxMpXmlOutMessage handle(WxMpXmlMessage message) {
    String msgType = message.getMsgType();
    MessageProcessor processor = processors.get(msgType);
    if (processor != null) {
      return processor.process(message);
    }
    return null;
  }
}

